package com.mzkj.wanjulaile.mobile.api.modules.brand.controller;

import com.mzkj.common.data.StatusCode;
import com.mzkj.wanjulaile.mobile.api.common.controller.BaseController;
import com.mzkj.wanjulaile.mobile.api.common.entity.ResultEntity;
import com.mzkj.wanjulaile.mobile.api.modules.brand.entity.Brand;
import com.mzkj.wanjulaile.mobile.api.modules.brand.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by wangxe on 2017/1/9.
 */
@Controller
@RequestMapping("/brand")
public class BrandController extends BaseController {

    @Autowired
    private BrandService brandService;

    /**
     * 热门品牌搜索
     * @param
     * @return
     */
    @RequestMapping("/hotBrand")
    @ResponseBody
    public ResultEntity<List<Brand>> getHotBrands() {

        ResultEntity<List<Brand>> resultEntity;
        List<Brand> brands;
        try {
            brands = brandService.getHotBrand(6);
            resultEntity = new ResultEntity<>(StatusCode.SC0, brands);
        } catch (Exception e) {
            resultEntity = new ResultEntity<>(StatusCode.SC5000, null);
        }
        return resultEntity;
    }
}
